//防抖

let debounce = function(fn,delay){
    
    let timer = null;
    return function(){
        window.clearTimeout(timer);
        timer = window.setTimeout(function(){
            fn()
        },delay)
    }
}

//节流

let throttle = function(fn,delay){
    
    let start = +new Date;
    return function(){
        let cur = +new Date;
        if(cur - start > delay){
            fn();
            start = cur
        }
    }
}

export {
    debounce,
    throttle
}
